// pages/a2/a2.js
Page({
  t: 0,
  data: {
    total: 3,
    navId: 1,
    buttonText: '显示答案',
    userSelect: '',
    navs: [
      {
        id: 1,
        label: '第一题',
        question: '下列字符中ASCII码值最小的是',
        question_img: '',
        answer: 'D',
        answer_img: '',
        options: [
        {code: 'A',
        option: 'a'
        },
        {code: 'B',
        option: 'Z'
        },
        {code: 'C',
        option: 'f'
        },
        {code: 'D',
        option: 'A'
        }
        ]
      },
        {
          id: 2,
          label: '第二题',
          question: '二进制1000转换成十六进制数是',
          question_img: '',
          answer: 'B',
          answer_img: '',
          options: [
          {code: 'A',
          option: '7'
          },
          {code: 'B',
          option: '8'
          },
          {code: 'C',
          option: '9'
          },
          {code: 'D',
          option: 'A'
          }
          ]
        },
        {
            id: 3,
            label: '第三题',
            question: '以下叙述正确的是',
            question_img: '',
            answer: 'A',
            answer_img: '',
            options: [
            {code: 'A',
            option: '构成C程序基本单位的是函数'
            },
            {code: 'B',
            option: '可以在一个函数中定义另一个函数'
            },
            {code: 'C',
            option: 'main()函数必须放在其他函数之前'
            },
            {code: 'D',
            option: '所有被调用的函数一定要在调用前定义'
            }
            ]
        },
        {
          id: 4,
          label: '第四题',
          question: '以下正确的C语言变量名是',
          question_img: '',
          answer: 'C',
          answer_img: '',
          options: [
          {code: 'A',
          option: '%K'
          },
          {code: 'B',
          option: 'a+b'
          },
          {code: 'C',
          option: 'a123'
          },
          {code: 'D',
          option: 'test!'
          }
          ]
          },
        {
          id: 5,
          label: '第五题',
          question: '第一个结构化程序设计语言是',
          question_img: '',
          answer: 'A',
          answer_img: '',
          options: [
          {code: 'A',
          option: 'PASCAL'
          },
          {code: 'B',
          option: 'C'
          },
          {code: 'C',
          option: 'BASIC'
          },
          {code: 'D',
          option: 'FORTRAN'
          }
          ]
        },
        {
          id: 6,
          label: '第六题',
          question: '设有语句：int a = 3 , b =5, m; 则执行语句：（m = a<=3）&& a+b<8 后，m的值为',
          question_img: '',
          answer: 'B',
          answer_img: '',
          options: [
          {code: 'A',
          option: '0'
          },
          {code: 'B',
          option: '1'
          },
          {code: 'C',
          option: '2'
          },
          {code: 'D',
          option: '3'
          }
          ]
          },
        {
            id: 7,
            label: '第七题',
            question: '设int x=-1;执行表达式++x||++x||++x后，x的值是',
            question_img: '',
            answer: 'C',
            answer_img: '',
            options: [
            {code: 'A',
            option: '3'
            },
            {code: 'B',
            option: '2'
            },
            {code: 'C',
            option: '1'
            },
            {code: 'D',
            option: '0'
            }
            ]
          },
          {
              id: 8,
              label: '第八题',
              question: '有以下程序段int  k=0;while(k!=1)  k++，while 循环执行的次数是',
              question_img: '',
              answer: 'A',
              answer_img: '',
              options: [
              {code: 'A',
              option: '一次'
              },
              {code: 'B',
              option: '语法有错，不能执行'
              },
              {code: 'C',
              option: '零次'
              },
              {code: 'D',
              option: '无限次'
              }
              ]
            },
            {
                id: 9,
                label: '第九题',
                question: '有int型变量x、y、z，语句“if ( x>y ) z=0; else z=1;” 和_____等价',
                question_img: '',
                answer: 'C',
                answer_img: '',
                options: [
                {code: 'A',
                option: 'A.z = (x>y)?1:0;'
                },
                {code: 'B',
                option: 'z = x>y;'
                },
                {code: 'C',
                option: 'z = x<=y;'
                },
                {code: 'D',
                option: 'z = x<=y ? 0 : 1;'
                }
                ]
            },
            {
                id: 10,
                label: '第十题',
                question: '关于switch语句，下列说法中不正确的是_____',
                question_img: '',
                answer: 'A',
                answer_img: '',
                options: [
                {code: 'A',
                option: 'case语句必须以break结束'
                },
                {code: 'B',
                option: 'default分支可以没有'
                },
                {code: 'C',
                option: 'switch后面的表达式可以是整型或字符型'
                },
                {code: 'D',
                option: 'case后面的常量值必须唯一'
                }
                ]
            },
          {
              id: 11,
              label: '第十一题',
              question: '若a、b已定义为int 类型的变量，则执行以下语句后b的值是____',
              question_img: '',
              answer: 'D',
              answer_img: '',
              options: [
              {code: 'A',
              option: '9'
              },
              {code: 'B',
              option: '-2'
              },
              {code: 'C',
              option: '-1'
              },
              {code: 'D',
              option: '8'
              }
              ]
          },
          {
                id: 12,
                label: '第十二题',
                question: '为了避免嵌套的 if-else 语义的二义性，C 语言规定 else 总是与____。',
                question_img: '',
                answer: 'C',
                answer_img: '',
                options: [
                {code: 'A',
                option: '缩排位置相同的 if'
                },
                {code: 'B',
                option: '在其之前未配对的 if'
                },
                {code: 'C',
                option: '在其之前未配对的最近的 if'
                },
                {code: 'D',
                option: '同一行上的 if'
                }
                ]
          },
          {
            id: 13,
            label: '第十三题',
            question: '有以下程序\n\nint  fun(int x,int y)\n{return(x+y);}\n\nint  main()\n{  	int a=1,b=2,\nc=3,sum;\nsum=fun((a++,b++,a+b),c++);\nprintf("%d\\n",sum);\nreturn 0;\n}\n执行后的输出结果是_______',
            question_img: '',
            answer: 'C',
            answer_img: '',
            options: [
            {code: 'A',
            option: '5'
            },
            {code: 'B',
            option: '7'
            },
            {code: 'C',
            option: '8'
            },
            {code: 'D',
            option: '3'
            }
            ]
            },
            {
              id: 14,
              label: '第十四题',
              question: '下列哪一种变量一定不是局部变量________。',
              question_img: '',
              answer: 'C',
              answer_img: '',
              options: [
              {code: 'A',
              option: '.静态变量'
              },
              {code: 'B',
              option: '形式参数变量'
              },
              {code: 'C',
              option: '外部变量'
              },
              {code: 'D',
              option: '自动局部变量'
              }
              ]
              },
          {
                id: 15,
                label: '第十五题',
                question: '若有定义：int a[2][3];， 以下选项中对a 数组元素正确引用的是_______ 。',
                question_img: '',
                answer: 'D',
                answer_img: '',
                options: [
                {code: 'A',
                option: 'a[2][!1]'
                },
                {code: 'B',
                option: '.a[2][3]'
                },
                {code: 'C',
                option: 'a [0][3]'
                },
                {code: 'D',
                option: 'a[1>2][!1]'
                }
                ]
          },
          {
            id: 16,
            label: '第十六题',
            question: '有以下C程序\n#include <stdio.h>\n#define N 20\nvoid fun(int a[],int n,int m)\n{\nint i,j;\nfor(i=m;i>=n;i--)\na[i+1]=a[i];\n}\nint main()\n{\nint i,a[N]={1,2,3,4,5,6,7,8,9,10};\nfun(a,2,9);\nfor(i=0;i<5;i++)\nprintf("%d",a[i]);\nreturn 0;\n}\n程序运行后的输出结果是________',
            question_img: '',
            answer: 'C',
            answer_img: '',
            options: [
            {code: 'A',
            option: '10234'
            },
            {code: 'B',
            option: '.12344'
            },
            {code: 'C',
            option: '12334'
            },
            {code: 'D',
            option: '12234'
            }
            ]
            },
            {
              id:17,
              label: '第十七题',
              question:'下面程序中有错误的行是 （每行程序前面的数字表示行号）_______。\n1 	int  main()\n2 	{int  a[3]={1};\n3		int i;\n4		scanf("%d",a);\n5for(i=1;i<=3;i++)a[0]=a[0]+a[i];\n6		printf("a[0]=%d\\n",a[0]);\n7 		return 0;\n8	}',
              question_img: '',
              answer: 'B',
              answer_img: '',
              options: [
              {code: 'A',
              option: '2'
              },
              {code: 'B',
              option: '5'
              },
              {code: 'C',
              option: '6'
              },
              {code: 'D',
              option: '4'
              }
              ]
        },
        {
          id: 18,
          label: '第十八题',
          question: '设int  *p, x, a[5]={1,2,3,4,5};  p=a; 能使x的值为2的语句是_______。',
          question_img: '',
          answer: 'D',
          answer_img: '',
          options: [
          {code: 'A',
          option: 'x=a[2];	'
          },
          {code: 'B',
          option: 'x=*(p+2);'
          },
          {code: 'C',
          option: 'a++; x=*a;'
          },
          {code: 'D',
          option: 'x=*(a+1); '
          }
          ]
        },
        {
          id: 19,
          label: '第十九题',
          question: '若char a[7]={\'p\',\'r\',\'o\',\'g\',\'r\',\'a\',\'m\'};\nchar *p=a;表达式____________能得到字符\'o\'',
          question_img: '',
          answer: 'B',
          answer_img: '',
          options: [
          {code: 'A',
          option: '*p+2;	'
          },
          {code: 'B',
          option: '*(p+2)	'
          },
          {code: 'C',
          option: 'p+2'
          },
          {code: 'D',
          option: '.p++,*p '
          }
          ]
          },
          {
            id:20,
            label: '第二十题',
            question:'若定义int m[10]={9,4,12,8,2,10,7,5,1,3},*p=m;下列哪一个表达式的结果与其他3个表达式的结果不同________。',
            question_img: '',
            answer: 'B',
            answer_img: '',
            options: [
            {code: 'A',
            option: 'sizeof(p)'
            },
            {code: 'B',
            option: 'sizeof(m)'
            },
            {code: 'C',
            option: 'sizeof(*m)	'
            },
            {code: 'D',
            option: 'sizeof(*p)'
            }
            ]
        },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  itemTap (ev) {
    const id = ev.target.dataset.id
    this.setData({
      //navId: 'n'+id,
      userSelect: '',
      navId: id
      //toView: 'n' + (id-1)
    })
  },
  submit(ev){
    let ac = this.data.appear
    //let ab = ev.target.dataset.navs.a
    this.setData({
      appear: !ac,
      buttonText: ac?'显示答案':'收回答案'
    })
  },
  radioChange(e){
    let a = e.detail.value
    this.setData({
      userSelect: a
    })
  }
})